﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevFx.Model;
using System.Data.Objects;
using DevFx.FrameWork.Data;

namespace DevFx.Biz
{
    public class UserRoleBiz : BaseBiz<SysUserRole>
    {
        public IQueryable<SysUserRole2> getListByUserID(Guid uid)
        {
            Model.Entities db = DbHelper.GetCurrentDb();
            var query = from a in db.SysUserRoles
                    join b in db.SysRoles on a.RoleID equals b.RoleID
                    join c in db.SysUsers on a.UserID equals c.UserID
                    where a.UserID.Value == uid
                        select new SysUserRole2
                        {
                            UserRoleID = a.UserRoleID,
                            UserName = c.UserName,
                        RoleID=a.RoleID.Value,RoleName=b.RoleName  };
            return query;
        }
        public IQueryable<SysUserRole2> getListByRoleID(Guid Rid)
        {

            Model.Entities db = DbHelper.GetCurrentDb();
            var query = from a in db.SysUserRoles
                        join b in db.SysRoles on a.RoleID equals b.RoleID
                        join c in db.SysUsers on a.UserID equals c.UserID
                        where a.RoleID.Value == Rid
                        select new SysUserRole2
                        {
                            UserRoleID = a.UserRoleID,
                            UserName = c.UserName,
                            RoleID = a.RoleID.Value,
                            RoleName = b.RoleName,
                            UserID=a.UserID.Value
                        };
            return query;
        }
    }
}

